﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SusuCMS.Web.Areas.Admin.Models;
using System.Web.Helpers;

namespace SusuCMS.Web.Areas.Admin.Controllers
{
    [HandleError]
    public class HomeController : AdminControllerBase
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Setting()
        {
            return View();
        }

        public ActionResult CreateUser()
        {
            var salt = Crypto.GenerateSalt();
            var user = new User
            {
                UserName = "admin",
                Email = "admin@gmail.com",
                Salt = salt,
                Password = Crypto.HashPassword(string.Concat("admin", salt)),
                CreateTime = DateTime.Now,
            };
            try
            {
                UserRepository.Add(user);
                UnitOfWork.Save();
                TempData["Message"] = "Create User Successfully";
                //return RedirectToIndex();
            }
            catch
            {
                TempData["ErrorMessage"] = "Create User Failed";
            }

            return View();
        }
    }
}
